package com.situ.orderingsystem.service.impl;

import com.situ.orderingsystem.dao.EmployeeDao;
import com.situ.orderingsystem.dao.OrderDao;
import com.situ.orderingsystem.dao.impl.EmployeeDaoImpl;
import com.situ.orderingsystem.dao.impl.OrderDaoImpl;
import com.situ.orderingsystem.model.Employee;
import com.situ.orderingsystem.model.EmployeeSerchBean;
import com.situ.orderingsystem.model.Order;
import com.situ.orderingsystem.model.OrderSearchBean;
import com.situ.orderingsystem.service.OrderService;
import com.situ.orderingsystem.utils.BeanFactory;
import com.situ.orderingsystem.utils.PaginateInfo;

import java.util.List;

public class OrderServiceImpl implements OrderService {
    private final OrderDao dao = BeanFactory.getBean(OrderDaoImpl.class);

    @Override
    public List<Order> findAll(OrderSearchBean ob, PaginateInfo pi) {
        return dao.findAll(ob,pi);
    }
    public List<Order> findAll() {
        return dao.findAll();
    }

    @Override
    public int deleteByIds(Integer[] ids) {
        int rows=0;
        for(Integer id :ids){
            boolean b = dao.deleteById(id) ;
            if(b){
                rows++;
            }
        }
        return  rows;
    }

    @Override
    public boolean save(Order order) {
        return  dao.add(order) > 0;
    }

    @Override
    public Order searchById(Integer id) {
        return  dao.searchById(id);
    }

    @Override
    public boolean update(Order order) {
        return dao.update(order)  > 0;
    }
}
